/*
* 解析url参数
* @example ?id=ljh&a=b
* @return Object {id:ljh,a:b}
* */
export function urlParse () {
  let url = window.location.search
  let obj = {}
  let reg = /[?&][^?&]+=[^?&]+/g
  let arr = url.match(reg)
  // ['?id=ljh','&a=b']
  // console.log(url)
  if (arr) {
    arr.forEach((item) => {
      let tempArr = item.substring(1).split('=')
      let key = decodeURIComponent(tempArr[0])
      // console.log(key)
      let val = decodeURIComponent(tempArr[1])
      obj[key] = val
      // console.log(obj[key])
    })
  }
  // console.log()
  return obj
}
